import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 资产类型信息 */
export interface AssetType {
  id: number // 编号
  name?: string // 分类
  parentId?: number // 父编号
  description: string // 说明
  children?: AssetType[]
}

// 资产类型 API
export const AssetTypeApi = {
  // 查询资产类型列表
  getAssetTypeList: async (params) => {
    return await request.get({ url: `/dorm/asset-type/list`, params })
  },
  // 获取素有资产类型列表
  getAllAssetType: async () => {
    return await request.get({ url: `/dorm/asset-type/all` })
  },
  // 查询资产类型详情
  getAssetType: async (id: number) => {
    return await request.get({ url: `/dorm/asset-type/get?id=` + id })
  },

  // 新增资产类型
  createAssetType: async (data: AssetType) => {
    return await request.post({ url: `/dorm/asset-type/create`, data })
  },

  // 修改资产类型
  updateAssetType: async (data: AssetType) => {
    return await request.put({ url: `/dorm/asset-type/update`, data })
  },

  // 删除资产类型
  deleteAssetType: async (id: number) => {
    return await request.delete({ url: `/dorm/asset-type/delete?id=` + id })
  },

  // 导出资产类型 Excel
  exportAssetType: async (params) => {
    return await request.download({ url: `/dorm/asset-type/export-excel`, params })
  }
}
